<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>个人中心</title>
    <link rel="stylesheet" href="/home/css/reset.css">
    <link rel="stylesheet" href="/home/css/head-footer.css">
    <link rel="stylesheet" href="/home/css/user-center.css">
</head>

<body>
{include file='base/header' /}

<div class="user-center-wrap">
    <div class="user-center">
        <div class="bread-nav">
                <span>
                    <a href="javascript:void(0)">首页 ></a>
                </span>
            <span>
                    <a href="javascript:void(0)">用户中心</a>
                </span>
        </div>
        <div class="user-center-main clearfixa">
                {include file='base/menu' /}
            <div class="user-center-right fr">
                <div class="base-data-list data-list data-list data-list-show">
                    <!-- 所有页面右侧标题 -->
                    <p class="user-center-nav-title">
                        修改员工信息
                    </p>
                    <div class="base-data-box">
                        <form>
                            <input type="hidden" name="b_id" id="b_id" value="<?php echo $employee_data['b_id'] ?>">
                            <!-- 无注释大的input框 -->
                            <div class="form-top-space">
                                <label for="" class="information-nav-title">
                                    <sup>*</sup>员工姓名：
                                </label>
                                <input type="text" id="employee_name" class="big-inputbox" name="employee_name" value="<?php echo $employee_data['employee_name'] ?>">
                            </div>
                            <div class="form-top-space">
                                <label for="" class="information-nav-title">
                                    <sup>*</sup>联系电话：
                                </label>
                                <input type="text" id="employee_mobile" class="big-inputbox" name="employee_mobile" value="<?php echo $employee_data['employee_mobile'] ?>">
                            </div>
                            <div class="form-top-space">
                                <label for="" class="information-nav-title">
                                    <sup>*</sup>登录账号：
                                </label>
                                <input type="text" id="employee_loginnum" class="big-inputbox" name="employee_loginnum" value="<?php echo $login_data['username'] ?>">
                            </div>
                            <!-- 和input框对其的圆角提交按钮 -->
                            <input class="align-savebtn" type="button" value="保存修改" id="button" />

                        </form>
                    </div>
                </div>

            </div>

        </div>
    </div>
</div>
{include file='base/footer' /}
</body>

</html>
<script src="http://libs.baidu.com/jquery/2.1.1/jquery.min.js"></script>
<script src="/home/js/layer-v/layer/layer.js"></script>

<script>
    var flag = false;
     
     $(document).on('blur','#employee_name',function()
       {
            var name = $(this).val();
            
            var regname = /^[\u4e00-\u9fa5]+$/;

            if(name == "" || name.length < 2 || !regname.test(name))
            {
                layer.tips('姓名必须为中文,不为空！', '#employee_name'); 

                flag = false;
            }else
            {
                flag = true;
            }
       })
       $(document).on('blur','#employee_mobile',function()
       {
            var loginnum = $(this).val();


            var regloginnum = /^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$/;

            if(loginnum == "" || loginnum.length < 3 || regloginnum.test(loginnum))
            {
                layer.tips('手机号格式不对', '#employee_loginnum');

                flag = false;
            }else
            {
                flag = true;
            }
       })
     $(document).on('blur','#employee',function()
       {
            var tel = $(this).val();

            var regtel = /^[\d]{5,11}$/;

            if(!regtel.test(tel))
            {
                layer.tips('电话格式不正确！', '#employee_mobile');

                flag = false;
            }
            else
            {
                flag = true;
            }      
       })
       $(document).on('blur','#employee_password',function()
       {
            var pwd = $(this).val();

            var regpwd = /^[a-zA-Z][a-zA-Z0-9_]{5,20}$/;

            if(!regpwd.test(pwd))
            {
                layer.tips('密码首字母必须为英文字母，不得小于6位！', '#employee_password');

                flag = false;
            }else
            {
                flag = true;
            }   
       })
       $(document).on('click','#button',function(){
            // if(flag == false)
            // {
            //     layer.msg('请填写完整员工资料！', function(){
            //     //关闭后的操作
            //      return false;
            //     });
               
            // }else
            // {              
                var employee_name = $('#employee_name').val();
                var employee_mobile = $('#employee_mobile').val();
                var employee_loginnum = $('#employee_loginnum').val();
                var b_id = $('#b_id').val();
                $.ajax({
                    url:"{:url('base/doUpdemployee')}",
                    data:{
                        employee_name:employee_name,
                        employee_mobile:employee_mobile,
                        employee_loginnum:employee_loginnum,
                        b_id:b_id
                    },
                    dataType:'json',
                    type:'post',
                    success:function(data)
                    {
                        if(data.code == '1000')
                        {
                              layer.msg('修改失败', {
                              icon: 16
                              ,shade: 0.01
                            });
                            window.location.href = 'employeelist';
                        }else
                        {
                            layer.msg('修改成功', {
                              icon: 16
                              ,shade: 0.01
                            });
                            window.location.href = 'employeelist';
                        }                      
                    }
                })
            // }
        });  
</script>